package org.ovirt.microvirt.services.situation.impl;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;

import org.ovirt.microvirt.beans.Host;
import org.ovirt.microvirt.services.situation.HostSituationService;

public class HostCheckListener implements MessageListener {

	public HostCheckListener(HostSituationService hostSituationService) {
		super();
		this.hostSituationService = hostSituationService;
	}

	final HostSituationService hostSituationService;

	@Override
	public void onMessage(Message message) {

		try {
			hostSituationService.checkHostStatus((Host) ((ObjectMessage) message)
					.getObject());
		} catch (JMSException e) {
			throw new RuntimeException(e);
		}

	}

}
